<div class="row wrapper border-bottom white-bg page-heading">
    <div class="col-md-6">
        <h2>商品管理</h2>
        <ol class="breadcrumb">
            <li>
                <a href="{:U('admin/Index/index')}">主页</a>
            </li>
            <li class="active">
                <strong>商品管理</strong>
            </li>
        </ol>
    </div>
    <div class="col-md-6">
        <h2><a href="{:U('admin/Product/add')}" class="btn btn-info pull-right">商品添加</a></h2>
    </div>
</div>
<div class="wrapper wrapper-content">
  	<div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>商品管理</h5>
        </div>
        <div class="ibox-content">
            <table class="table table-hover table-bordered">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>商品名称</th>
                    <th>分类</th>
                    <th>价格</th>
                    <th>库存</th>
                    <th>状态</th>
                    <th style="text-align:center">操作</th>
                </tr>
                </thead>
                <tbody>
				<volist name="products" id="vo">
					<tr class="tr">
                        <td class="id">{$vo.id}</td>
						<td><img src="__ROOT__{$vo.img}" style="width:60px" /><span style="margin-left:10px">{$vo.title}</span></td>
                        <?php $catalog=M("product_catalog")->where('id='.$vo['catalog_id'])->find()?>
	                    <td>{$catalog.name}</td>
	                    <td>￥{$vo.price}</td>
	                    <td>{$vo.stock}</td>
	                    <td>{$vo.status|product_status}</td>
	                    <td style="text-align:center">
                            <if condition="$vo['status'] eq 0"><a href="{:U('admin/product/ban/id/'.$vo['id'])}" class="btn btn-warning btn-sm ban">下架</a>
                            <else/><a href="{:U('admin/product/enable/id/'.$vo['id'])}" class="btn btn-success btn-sm enable">上架</a>
                            </if>
	                    	<a href="{:U('admin/product/edit/id/'.$vo['id'])}" class="btn btn-primary btn-sm">编辑</a>
	                    	<a href="{:U('admin/product/del/id/'.$vo['id'])}" class="btn btn-danger btn-sm delete">删除</a>
	                    </td>
	                </tr>
				</volist>
                </tbody>
            </table>
            {$page}
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.ban').click(function(){
        var id=$(this).parents('.tr').find('.id').html();
        $.post('{:U("admin/product/ban")}',{id:id},function(data){
            if(data=='ok'){
                location.reload();
            }
        })
        return false;
    });
    $('.enable').click(function(){
        var id=$(this).parents('.tr').find('.id').html();
        $.post('{:U("admin/product/enable")}',{id:id},function(data){
            if(data=='ok'){
                location.reload();
            }
        })
        return false;
    });
</script>

        